package chai.ningning.myself;

public class Page129 {

    static class FirstThread extends Thread{
        @Override
        public void run() {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()+"运行到第"+i+"次");
                Thread.yield();
            }
        }
    }

   /* static class SecondThread extends Thread{
        @Override
        public void run() {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()+"运行到第"+i+"次");
                Thread.yield();
            }
        }
    }*/

    public static void main(String[] args) {
        Thread.currentThread().setName("主线程");
        FirstThread f1 = new FirstThread();
       // SecondThread s2 = new SecondThread();
        f1.setName("子线程");
        f1.start();
       // s2.start();

        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()+"运行到第"+i+"次");
            Thread.yield();
        }
    }
}

